package com.tjsinfo.backworkflow.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import com.tjsinfo.backworkflow.service.ICommendService;
import com.tjsinfo.backworkflow.service.IPinYinServcie;

@Controller
@RequestMapping("/pinyin")
public class PinYin4JController {
	
	@Value("#{config[DATE]}")
	private  String DATE;
	
	@Autowired
	private ICommendService commendService;
	
	@Autowired
	private IPinYinServcie pinYinServcie;
	
	@RequestMapping("/pinyinview")
	public ModelAndView pinyinview(String  username){
		ModelAndView modelAndView = new ModelAndView();
		if(commendService.compare_date(DATE)){
			String pinyin =  pinYinServcie.toPinYin(username);
			modelAndView.addObject("pinyin", pinyin);
			modelAndView.setViewName("pinyinview");
		}else{
			modelAndView.setViewName("pinyinviewError");
		}
		
		return modelAndView;
	}
	
	@RequestMapping("/selectview")
	public ModelAndView selectview(){
		ModelAndView modelAndView = new ModelAndView();
		if(commendService.compare_date(DATE)){
			modelAndView.setViewName("selectview");
		}else{
			modelAndView.setViewName("pinyinviewError");
		}
		
		return modelAndView;
	}
}	
